In [1]:
%pylab inline
import matplotlib.pyplot as plt

from ipywidgets import *
Populating the interactive namespace from numpy and matplotlib

Minkowsky space-time

In [2]:
def Lorentz(V):
    '''
    Lorentz transformation
    '''
    th=V
    ch=1/sqrt(1-th**2)
    sh=th*ch
    Lm=matrix([[ch,-sh],[-sh,ch]])
    
    return(Lm)
In [3]:
def coords(V):
    '''
    Calculate the unit vectors 'xvec,tvec' along the axises x', t' in system K' 
    '''
    th=V
    szog=arctan(V)
    
    xvec=array([cos(szog),sin(szog)])
    tvec=array([cos(pi/2-szog),sin(pi/2-szog)])
    
    return(xvec,tvec)
In [4]:
def tengelyek(V):
    '''
    plotting x', t' axises in K' 
    '''
    figsize(12,8)
    #ax=subplot(aspect='equal')
    ax=subplot(111,aspect='equal')

    vecxv,vectv=coords(V)

    fact=5
    
    plot([0,fact*1],[0,0],'-b')
    plot([0,0],[0,fact*1],'-b')
    plot([0,fact*1],[0,fact*1],'--k')
    
    plot([-fact*vecxv[0],fact*vecxv[0]],[-fact*vecxv[1],fact*vecxv[1]],'-r')
    plot([-fact*vectv[0],fact*vectv[0]],[-fact*vectv[1],fact*vectv[1]],'-r');
    text(0,fact*1,'$t$',fontsize=20)
    text(fact*1,0,'$x$',fontsize=20)
    text(fact*vectv[0],fact*vectv[1],'$t^\prime$',fontsize=20)
    text(fact*vecxv[0],fact*vecxv[1],'$x^\prime$',fontsize=20)
    
    return(vecxv,vectv)

def indicatrix(chimax):
    '''
    plotting the indicatrix for x and t, ie units of x and t
    
    '''
    chi=linspace(-chimax,chimax,100)
    plot(sinh(chi),cosh(chi),'-',color='magenta');
    plot(cosh(chi),sinh(chi),'-',color='magenta');
In [5]:
def vetites(vecxv,vectv,Ep,betu,szin):
    '''
    calculation of the coordinates in skew coordinates, in K', projection
    '''
    #Ep  esemeny K-ban
    plot(Ep[0], Ep[1], marker='o', markersize=9, color=szin)
    pos=1.05
    text(pos*Ep[0], pos*Ep[1],betu,fontsize=20,color=szin)

    mm=array([[dot(vecxv,vecxv),dot(vecxv,vectv)],[dot(vectv,vecxv),dot(vectv,vectv)]])
    b=array([dot(vecxv,Ep),dot(vectv,Ep)])
    av = linalg.solve(mm, b)

    tmp=vecxv*av[0]
    plot([tmp[0],Ep[0]],[tmp[1],Ep[1]],'--',color=szin)
    tmp=vectv*av[1]
    plot([tmp[0],Ep[0]],[tmp[1],Ep[1]],'--',color=szin)
    
In [6]:
def rajz_esemeny(V,Ep,betu,szin):
    '''
    plotting the coordinates of the event Ep in K' if it is given in K. 
    '''
    
    vecxv,vectv=tengelyek(V)
    
    vetites(vecxv,vectv,Ep,betu,szin)

    grid();


def rajz_2esemeny(V,Ep1,Ep2,betu1,szin1,betu2,szin2):
    '''
    plotting the coordinates of the event Ep1 and Ep2 in K' if it is given in K. 
    '''
    
    vecxv,vectv=tengelyek(V)

    #Ep1  esemeny K-ban
    vetites(vecxv,vectv,Ep1,betu1,szin1)
    #Ep2  esemeny K-ban
    vetites(vecxv,vectv,Ep2,betu2,szin2)

    plot([Ep1[0],Ep2[0]],[Ep1[1],Ep2[1]],'-b',lw=3)
    
    grid();
In [7]:
Lm=Lorentz(0.6)
xk=matrix(array([[1],[6]]))
xkv=Lm*xk
Lm, Lm*xk,xkv,array(xkv)[1][0]
Out[7]:
(matrix([[ 1.25, -0.75],
         [-0.75,  1.25]]), matrix([[-3.25],
         [ 6.75]]), matrix([[-3.25],
         [ 6.75]]), 6.75)
In [8]:
V=-0.4
vecxv,vectv=tengelyek(V)
vecxv
Out[8]:
array([ 0.92847669, -0.37139068])
In [9]:
V=0.6
fact=3
Ep =fact*array([0.6,0.8])  # esemeny K-ban
rajz_esemeny(V,Ep,'E','r')

indicatrix(1.5)
In [10]:
fact=4

@interact(V=(-1,1,0.1),Epx=(0,1,0.1),Epy=(0,1,0.1))
def play(V=0.2,Epx=0.6,Epy=0.8):
    
    rajz_esemeny(V,fact*array([Epx,Epy]),'E','r')
    indicatrix(1.5)
    show();
In [11]:
V=0.25
fact=3
Ep1 =fact*array([0.3,0.8])  # esemeny K-ban
Ep2 =fact*array([0.6,0.8])  # esemeny K-ban

rajz_2esemeny(V,Ep1,Ep2,'A','r','B','limegreen')

indicatrix(1.2);
In [12]:
V=0.2
fact=3
Ep1 =fact*array([0.3,0.6])  # esemeny K-ban
Ep2 =fact*array([0.3,0.9])  # esemeny K-ban

rajz_2esemeny(V,Ep1,Ep2,'A','r','B','limegreen')
indicatrix(1.2)

#grid();
In [13]:
fact=4

@interact(V=(-1,1,0.05),Ep1x=(0,1,0.1),Ep1y=(0,1,0.1),Ep2x=(0,1,0.1),Ep2y=(0,1,0.1))
def play(V=0.25,Ep1x=0.3,Ep1y=0.8,Ep2x=0.6,Ep2y=0.8):
    
    rajz_2esemeny(V,fact*array([Ep1x,Ep1y]),fact*array([Ep2x,Ep2y]),'A','r','B','limegreen')
    indicatrix(1.5)
    show();